package cn.mgm.base;

import cn.mgm.senior.dao.impl.SysRoleDaoImpl;
import cn.mgm.senior.pojo.SysRole;
import cn.mgm.senior.util.JDBCUtilV2;
import org.junit.Test;

import java.sql.Connection;
import java.util.List;

public class JDBCUtilTest {

    @Test
    public void jdbcUtilV2Test(){

        Connection connection1 = JDBCUtilV2.getConnection();
        Connection connection2 = JDBCUtilV2.getConnection();
        Connection connection3 = JDBCUtilV2.getConnection();

        System.out.println(connection1);
        System.out.println(connection2);
        System.out.println(connection3);
    }


    @Test
    public void jdbcDaoQueryAllTest(){
        SysRoleDaoImpl sysRoleDao = new SysRoleDaoImpl();
        List<SysRole> sysRoleList = sysRoleDao.selectAll();
        System.out.println(sysRoleList);
    }

    @Test
    public void jdbcDaoQueryOneTest(){
        SysRoleDaoImpl sysRoleDao = new SysRoleDaoImpl();
        SysRole sysRole = sysRoleDao.selectById(1);
        System.out.println(sysRole);
    }

    @Test
    public void jdbcDaoInsertTest(){
        SysRoleDaoImpl sysRoleDao = new SysRoleDaoImpl();
        SysRole sysRole = new SysRole(null, "add", "ddd", "ccc");
        int i = sysRoleDao.insert(sysRole);
        System.out.println(i);
    }



    @Test
    public void jdbcDaoDeleteTest(){
        SysRoleDaoImpl sysRoleDao = new SysRoleDaoImpl();
        int i = sysRoleDao.delete(18);
        System.out.println(i);
    }
}
